package com.ubxtech.sentinel.handler;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.ubxtech.core.exception.RRException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

/**
 * 如果使用spring-cloud-starter-alibaba-sentinel 这里需要Component
 * @author Victor.Xiao
 * @since 2023-08-09 11:56
 **/
@Slf4j
@Component
//public class CustomBlockExceptionHandler implements BlockExceptionHandler {
//    @Override
//    public void handle(HttpServletRequest request, HttpServletResponse response, BlockException e) throws Exception {
//        log.warn("Blocked by Sentinel CustomBlockExceptionHandler: {}", e.getRule());
//        throw new RRException("too many request", 429);
//    }
//}

public class CustomBlockExceptionHandler {

}

